<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/displaytag-11.tld" prefix="display"%>

<link href="<%=request.getContextPath() + "/css/bloques.css"%>"
	rel="stylesheet" type="text/css">
<link href="<%=request.getContextPath() + "/css/table.css"%>"
	rel="stylesheet" type="text/css">


<script type="text/javascript">
  function buscarSubprogramas(){
    document.formListar.action = '<%=request.getContextPath()
					+ "/beneficios/OtorgarBeneficios.do"%>';
		document.formListar.submit();
	}

	function validarVacio() {

		if (document.formListar.codeSubPrograma.value != 'nulo') {
			document.formListar.continuar.disabled = false;
		} else {
			document.formListar.continuar.disabled = true;
		}
	}
</script>

<form name="formListar"
	action="<%=request.getContextPath() + "/beneficios/IngresoDatos.do"%>"
	method="get">

	<div align="center">
		<table class="tablaGenericaWidth70">
			<tr>
				<td class="titulosenblanco" colspan="2">
					<DIV align="center">
						<STRONG>OTORGAR BENEFICIOS</STRONG>
					</DIV>
				</td>
			</tr>
			<logic:notPresent name="beneSelected">
				<tr>
					<td class="titulosenblanco" colspan="2">No se encontro el
						beneficiario al que se le otorgara un beneficio</td>
				</tr>
			</logic:notPresent>
			<logic:present name="beneSelected">
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td class="titulosenblanco" colspan="2">Beneficiario</td>
				</tr>
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<logic:iterate id="bene" length="1" name="beneSelected">
					<tr>
						<td class="celdatabla" width="15%">Documento:</td>
						<td class="celdatabla" width="40%">
							<div class="form">
								<bean:write name="bene" property="numeroDocumento" />
							</div>
						</td>
						<td class="celdatabla" width="45%">&nbsp;</td>
					</tr>
					<tr>
						<td class="celdatabla" width="15%">Nombres:</td>
						<td class="celdatabla" width="40%">
							<div class="form">
								<bean:write name="bene" property="nombre1" />
								<bean:write name="bene" property="nombre2" />
							</div>
						</td>
						<td class="celdatabla" width="45%">&nbsp;</td>
					</tr>
					<tr>
						<td class="celdatabla" width="15%">Apellidos:</td>
						<td class="celdatabla" width="40%">
							<div class="form">
								<bean:write name="bene" property="primerApellido" />
								<bean:write name="bene" property="segundoApellido" />
							</div>
						</td>
						<td class="celdatabla" width="45%">&nbsp;</td>
					</tr>
				</logic:iterate>
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td class="titulosenblanco" colspan="2">Beneficio</td>
				</tr>
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td class="celdatabla" width="15%">Programa:</td>
					<td width="40%"><logic:notPresent name="programas">
							<DIV align="center">
								<%=session.getAttribute("msg")%>
								<%
									session.removeAttribute("msg");
								%>
							</DIV>
						</logic:notPresent> <%
 	Object codePrograma = request.getParameter("codePrograma");
 %>
						<div align="left">
							<logic:present name="programas">
								<logic:iterate id="programa" name="programas" length="1"
									type="com.cs.beneficios.business.model.ProgramaVO">
									<html:select name="programa" property="codePrograma"
										onchange="javascript: buscarSubprogramas();" title="Programa"
										styleClass="form" value="<%=(String) codePrograma%>">
										<option value="nulo">Seleccione un programa</option>
										<html:options name="programas" labelName="codigo"
											labelProperty="nombre" property="code" collection="programas" />
									</html:select>
								</logic:iterate>
							</logic:present>
						</div></td>
					<td class="celdatabla" width="45%">&nbsp;</td>
				</tr>
				<%
					if (codePrograma != null) {
				%>
				<tr>
					<td class="celdatabla" width="15%">Beneficio:</td>
					<td width="40%">
						<div align="left">
							<logic:notPresent name="subprogramas">
								<DIV align="center">
									<%=session.getAttribute("msg")%>
									<%
										session.removeAttribute("msg");
									%>
								</DIV>
							</logic:notPresent>
							<logic:present name="subprogramas">
								<logic:iterate id="subprograma" name="subprogramas" length="1"
									type="com.cs.beneficios.business.model.SubProgramaVO">
									<html:select name="subprograma" property="codeSubPrograma"
										title="Programa" styleClass="form" onchange="validarVacio();">
										<option value="nulo">Seleccione un subprograma</option>
										<html:options name="subprogramas" labelName="codigo"
											labelProperty="nombre" property="code"
											collection="subprogramas" />
									</html:select>
								</logic:iterate>
							</logic:present>
						</div>
					</td>
					<td class="celdatabla" width="45%">&nbsp;</td>
				</tr>
				<%
					}
				%>
				<tr>
					<td class="titulosenblanco" colspan="3">&nbsp;</td>
				</tr>
				<tr>
					<td class="celdatabla" width="15%">&nbsp;</td>
					<td width="40%">
						<div align="center">
							<input type="hidden" name="code"
								value="<%=request.getParameter("code")%>" /> <input
								type="submit" value="Continuar" disabled name="continuar" />
							<P>&nbsp;</P>
						</div>
					</td>
					<td class="celdatabla" width="45%">&nbsp;</td>
				</tr>

			</logic:present>

		</table>
	</div>
</form>






